<template>
  <div class="container-sex" style="position: relative">
    <div class="top">
      <p class="title">男女比例</p>
      <span class="deco"></span>
    </div>
    <div class="body">
      <div class="man"><img src="../../images/man.png" /></div>
      <div class="woman"><img src="../../images/woman.png" /></div>
    </div>
    <div
      class="ratio"
      style="
        display: flex;
        color: white;
        justify-content: space-between;
        margin-top: 25px;
      "
    >
      <span style="margin-left: 35px; font-size: 20px">男士58%</span>
      <span style="margin-right: 35px; font-size: 20px">女士42%</span>
    </div>
    <div
      class="sexBar"
      ref="sexBarRef"
      style="
        width: 100%;
        height: 60px;
        /* border: 1px solid skyblue; */
        position: absolute;
        padding: 0 0;
      "
    ></div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import * as echarts from "echarts";

const sexBarRef = ref();
onMounted(() => {
  // console.log(echarts);
  let mychart = echarts.init(sexBarRef.value);
  mychart.setOption({
    title: {
      text: "",
      textStyle: {
        color: "skyBlue",
      },
      left: "50%",
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: { show: false, type: "category" },
    series: [
      {
        type: "bar",
        data: [58],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: "skyblue",
          borderRadius: 20,
        },
      },
      {
        type: "bar",
        data: [100],
        barWidth: 20,
        barGap: "-100%",
        itemStyle: {
          color: "pink",
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 30,
      top: -25,
      right: 30,
      bottom: 0,
    },
  });
});
</script>

<style lang="scss" scoped>
.container-sex {
  margin: 10px 0px 0px 20px;
  background: url(../../images/dataScreen-main-lb.png) no-repeat;
  background-size: 100% 100%;
  // border: 1px solid cadetblue;
  .top {
    position: relative;
    // border: 1px solid red;
    height: 60px;
    .title {
      color: white;
      font-size: 20px;
    }
    .deco {
      background: url(../../images/dataScreen-title.png);
      display: inline-block;
      width: 68px;
      height: 7px;
    }
  }
  .body {
    color: white;
    display: flex;
    justify-content: center;
    padding-top: 10px;
    .man {
      background: url(../../images/man-bg.png) no-repeat;
      background-size: 100% 100%;
      width: 110px;
      height: 110px;
      display: flex;
      margin-right: 100px;
    }
    .woman {
      background: url(../../images/woman-bg.png) no-repeat;
      background-size: 100% 100%;
      width: 110px;
      height: 110px;
      display: flex;
    }
  }
}
</style>
